<?php
	require_once("../inc/models/order_details_model.php");
	if(isset($_POST['submit']))
	{
		$row = $_POST;
		NewOrderDetail($row);
		header("Location: index.php");
	}
	else
	{
		$customer = GetCustomers();	
		$product = GetProducts();
		$order = GetOrders();
	}
	?>
<!DOCTYPE html>
<html lang="en">
    <?php include('../inc/header.php'); ?>
        <body>
        <?php include('../inc/navigation.php'); ?>     
        <div class="span9">
        	<div class="row-fluid">
	        	<h2>Create new Order Detail</h2>       
	        	<form class="well" method="post" action="#">
						<div class=" control-group">
	                        <label class="control-label" for="order_id">Order:</label>
	                        <div class="controls">
	                        	<select name="order_id" id = "order_id">
	                        		<? while($rs = $order->fetch_assoc()): ?>
	                        			<option value="<?=$rs['id']?>"><?=$rs['id']?></option>
	                        		<?php endwhile; ?>                        		                    		
	                        	</select>                        	                            	
	                        </div>
	                    </div> 
	                    <div class=" control-group">
	                        <label class="control-label" for="product_id">Product:</label>
	                        <div class="controls">
	                        	<select name="product_id" id = "product_id">
	                        		<? while($rs = $product->fetch_assoc()): ?>
	                        			<option value="<?=$rs['id']?>"><?=$rs['name']?></option>
	                        		<?php endwhile; ?>                        		                    		
	                        	</select>                        	                            	
	                        </div>
	                    </div>     
	                    <div class=" control-group">
	                        <label class="control-label" for="name">Order Detail name:</label>
	                        <div class="controls">                        	
								<input type="text" name="name" id="name" />
						</div> 
						<div class=" control-group">
	                        <label class="control-label" for="price">Price:</label>
	                        <div class="controls">                        	
								<input type="text" name="price" id="price" />
						</div> 
						<div class=" control-group">
	                        <label class="control-label" for="quantity">Quantity:</label>
	                        <div class="controls">                        	
								<input type="text" name="quantity" id="quantity" />
						</div> 					                    
					 	<div class=" control-group">
	                        <label class="control-label" for="customer_id">Customer:</label>
	                        <div class="controls">
	                        	<select name="customer_id" id = "customer_id">
	                        		<? while($rs = $customer->fetch_assoc()): ?>
	                        			<option value="<?=$rs['id']?>"><?=$rs['FirstName']?> <?=$rs['LastName']?></option>
	                        		<?php endwhile; ?>                        		                    		
	                        	</select>                        	                            	
	                        </div>
	                    </div>
	                    <div class=" control-group">
	                        <label class="control-label" for="type">Type of Credit/Debit Card:</label>
	                        <div class="controls">                        	
								<input type="text" name="type" id="type" />
						</div> 
						<div class=" control-group">
	                        <label class="control-label" for="number">Card Number:</label>
	                        <div class="controls">                        	
								<input type="text" name="number" id="number" />
						</div>    
						<div class=" control-group">
	                        <label class="control-label" for="exp">Expiration Date:</label>
	                        <div class="controls">                        	
								<input type="text" name="exp" id="exp" />
						</div>             
						<input type="submit" name="submit" value="Submit" />
				</form>
			</div>
        </div>
        <!-- All Bootstrap JavaScript Files -->
        <script src="../inc/bootstrap/js/jquery.js"></script>
    	<script src="../inc/bootstrap/js/bootstrap.js"></script>
   </body>
</html>